import Vue from 'vue'
import * as filters from './filters'
import * as directives from './directives'
import 'remixicon/fonts/remixicon.css' //remixicon 图标库
import '@/fonts/digiface/digiface.css' // 电子字体
import elementUI from 'element-ui'
import { MessageBox } from 'element-ui'
import '@/styles/index.scss' // 全局样式
import gojs from 'gojs'
import DtChart from 'dt-chart'
Vue.prototype.$confirm = MessageBox.confirm

class AppLoader {
  constructor() {
    Vue.config.productionTip = false
    Vue.use(elementUI)
    Vue.use(gojs)
    Vue.use(DtChart)
    /**
     * 注册过滤器
     */
    Object.keys(filters).forEach(key => {
      Vue.filter(key, filters[key])
    })

    /**
     * 注册指令
     */
    Object.keys(directives).forEach(key => {
      Vue.use(directives[key])
    })
  }

  install() {
    try {
      global.Vue = Vue
    } catch (error) {
      console.log(error.message)
    }
  }
}

const appLoader = new AppLoader()
export default appLoader
